/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package connection;

import java.io.*;
import java.net.*;



public class Client {

    private ObjectOutputStream objOut;
    private Socket socket;


    public Client( InetSocketAddress address) throws IOException{
        
        String ip = address.getHostName().substring(address.getHostName().indexOf("/")+1);
       
        socket = new Socket(ip, address.getPort());
        objOut = new ObjectOutputStream(socket.getOutputStream());
      
    }


    public void sendPacket(Object packet) throws Exception{

            objOut.writeObject(packet);

    }


    public void closeSocket() throws IOException{
           socket.close();
    }


    public String toString(){
        return "IL server a cui sono collegato è  " + socket.getRemoteSocketAddress();
    }


}
